package readuncommit;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

public class Transaction1 {

    private static final String URL = "jdbc:mysql://localhost:3306/transaction_demo";
    private static final String USER = "root";
    private static final String PASSWORD = "123456";

    public static void main(String[] args) {
        try {;
             Connection conn = DriverManager.getConnection(URL, USER, PASSWORD);
             conn.setAutoCommit( false);
             Statement stmt = conn.createStatement();
             stmt.executeUpdate("INSERT INTO account (id, name, balance) VALUES (3,'C', 1000)");
             System.out.println("暂停");
             conn.rollback();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}
